<template>
  <div class="app-container">
    <el-button-group style="margin-bottom: 15px">
      <el-button type="primary" size="small" @click="drawer = true"
        >新增题目</el-button
      >
      <!-- <el-button type="primary">下一页</el-button> -->
    </el-button-group>
    <!--  -->
    <el-table style="width: 100%; margin: 10px auto" height="330" :data="list">
      <el-table-column
        fixed
        type="index"
        label="#"
        width="50"
      ></el-table-column>
      <el-table-column
        fixed
        prop="title"
        label="题目"
        width="300"
      ></el-table-column>
      <el-table-column prop="type" label="分类" width="100"></el-table-column>
      <el-table-column prop="author" label="作者" width="100">
        <template>郜司徒</template>
      </el-table-column>
      <el-table-column
        prop="date"
        label="发布时间"
        sortable
        width="200"
      ></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
            >编辑</el-button
          >
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <!--  -->
    <el-drawer
      title="我是标题"
      size="45%"
      :visible.sync="drawer"
      :with-header="false"
    >
      <div style="padding:50px 20px 20px 20px">
        <!-- <el-page-header title="关闭" @back="drawer = false"> </el-page-header> -->
        <el-form ref="form" :model="form" label-width="80px">
          <el-form-item label="题目">
            <el-input
              type="textarea"
              placeholder="请输入内容"
              v-model="form.items"
              autosize
            ></el-input>
          </el-form-item>
          <el-form-item label="分类">
            <el-select size="small" v-model="form.cid" placeholder="请选择">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="选项">
            <el-checkbox-group v-model="form.options">
              <div v-for="(item,index) in initOptions" :key="index" class="checkbox-row">
                <el-checkbox :label="item.text"></el-checkbox>
                <el-input
                  type="textarea"
                  placeholder="请输入内容"
                  v-model="item.value"
                  autosize
                ></el-input>
              </div>
              <!-- <div class="checkbox-row">
                <el-checkbox label="B"></el-checkbox>
                <el-input
                  type="textarea"
                  placeholder="请输入内容"
                  v-model="form.items"
                  autosize
                ></el-input>
              </div>
              <div class="checkbox-row">
                <el-checkbox label="C"></el-checkbox>
                <el-input
                  type="textarea"
                  placeholder="请输入内容"
                  v-model="form.items"
                  autosize
                ></el-input>
              </div>
              <div class="checkbox-row">
                <el-checkbox label="D"></el-checkbox>
                <el-input
                  type="textarea"
                  placeholder="请输入内容"
                  v-model="form.items"
                  autosize
                ></el-input>
                <el-button
                  type="primary"
                  icon="el-icon-plus"
                  size="small"
                  circle
                ></el-button>
                <el-button
                  type="danger"
                  icon="el-icon-minus"
                  circle
                ></el-button>
              </div> -->
            </el-checkbox-group>
          </el-form-item>
          <el-form-item label="答案">
            <div>A,B,C</div>
          </el-form-item>
          <el-form-item label="答题提示">
            <el-input
              type="textarea"
              placeholder="请输入内容"
              v-model="form.items"
              autosize
            ></el-input>
          </el-form-item>
          <div class="btn-bottom">
            <el-button size="small" type="primary" @click="drawer = false"
              >保存</el-button
            >
            <el-button size="small" @click="drawer = false">取消</el-button>
          </div>
        </el-form>
      </div>
    </el-drawer>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [],
      drawer: false,
      initOptions:[
        { text: "A", value: ""},
        { text: "B", value: ""},
        { text: "C", value: ""},
        { text: "D", value: ""},
      ],
      form: {
        options: [],
      },
      options: [
        {
          value: "选项1",
          label: "黄金糕",
        },
        {
          value: "选项2",
          label: "双皮奶",
        },
        {
          value: "选项3",
          label: "蚵仔煎",
        },
        {
          value: "选项4",
          label: "龙须面",
        },
        {
          value: "选项5",
          label: "北京烤鸭",
        },
      ],
    };
  },
  layout: "main",
};
</script>

<style scoped>
.checkbox-row {
  display: flex;
}

.checkbox-row .el-textarea {
  margin-left: 10px;
}

.btn-bottom {
  margin-left: 80px;
}
</style>